// 图书信息
<template>
<div>
    <el-table
    :data="tableData"
    style="width: 100%"
    v-loading = "isLoading"
      element-loading-text = "数据正在加载中"
      element-loading-spinner = "el-icon-loading"
    :default-sort = "{prop: 'date', order: 'descending'}"
    >
    <!-- <el-table-column
      prop="index"
      label=""
      sortable
      width="180">
    </el-table-column> -->
    <el-table-column
      label="图书编号"
      prop="tsbh">
    </el-table-column>
    <el-table-column
      label="图书名称"
      prop="tsmc">
    </el-table-column>
    <el-table-column
      label="图书分类"
      prop="tsfl">
    </el-table-column>
    <el-table-column
      label="作者姓名"
      prop="zzxm">
    </el-table-column>
    <el-table-column
      label="出版社"
      prop="cbs">
    </el-table-column>
    <el-table-column
      label="定价"
      prop="dj">
    </el-table-column>
    <el-table-column
      label="出版日期"
      prop="cbrq">
    </el-table-column>
    <el-table-column
      label="状态"
      prop="zt">
    </el-table-column>
    
  </el-table>
  <div class="flexRight">
      <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page='currentPage'
      :page-sizes="[10, 15, 20, 30, 40]"
      :page-size='size'
      :layout="mylayout"
      :total='total'>
    </el-pagination>
  </div>
</div>
  
</template>

<script>
import '../../utils/isShowTotalNumber.js'
export default {
    name:'BookInfo',
    data(){
        return{
            isLoading:true,
            tableData:[],
            total:0,
            size:15,
            currentPage:1,
            schoolCode:'',
            mylayout:''
        }
    },
    created(){
        this.schoolCode = JSON.parse(sessionStorage.getItem('school')).school_code
        this.getResultData(this.currentPage, this.size)
        this.mylayout = window.mylayout
    //     var roleId = JSON.parse(localStorage.getItem("USER")).roleId;
    // if (roleId.includes("99")) {
    //   this.mylayout = "sizes, prev, pager, next, jumper";
    // } else {
    //   this.mylayout = "total, sizes, prev, pager, next, jumper";
    // }
    },
    mounted(){

    },
    methods:{
         handleSizeChange(val) {
        this.size=val
        this.isLoading=true
        this.getResultData(this.currentPage, val)

      },
      handleCurrentChange(val) {
        this.isLoading=true
        this.currentPage=val
        this.getResultData(val, this.size)
      },
        getResultData(){
            let param = {
                // xydm: this.schoolCode,
                currentPage:this.currentPage,
                size:this.size,
            }
            this.$post2('dataCenter/select/listTSB', JSON.stringify(param)).then(r=>{
                this.tableData = r.data.records
                this.total=r.data.total
                this.isLoading=false
            })
        }
    }

}
</script>



